package com.basic.business.optimizeActions.controller;


import com.basic.business.optimizeActions.domain.TOptimizeActions;
import com.basic.business.optimizeActions.service.ITOptimizeActionsService;
import com.basic.common.annotation.FileExport;
import com.basic.common.annotation.Log;
import com.basic.common.core.controller.BaseController;
import com.basic.common.core.domain.AjaxResult;
import com.basic.common.core.page.TableDataInfo;
import com.basic.common.enums.BusinessType;
import com.basic.common.utils.easyExcel.EasyExcelUtils;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.io.IOException;
import java.util.List;

/**
 * 优化动作管理Controller
 *
 * @author zhaoxy_jn@163.com
 */
@RestController
@RequestMapping("/business/optimizeActions")
public class TOptimizeActionsController extends BaseController
{
    @Resource
    private ITOptimizeActionsService tOptimizeActionsService;

    /**
     * 查询优化动作管理列表
     */
    @PreAuthorize("@ss.hasPermi('business:optimizeActions:list')")
    @GetMapping("/list")
    public TableDataInfo list(TOptimizeActions tOptimizeActions)
    {
        startPage();
        List<TOptimizeActions> list = tOptimizeActionsService.getList(tOptimizeActions);
        return getDataTable(list);
    }

    /**
     * 导出优化动作管理列表
     */
    @PreAuthorize("@ss.hasPermi('business:optimizeActions:export')")
    @Log(title = "优化动作管理", businessType = BusinessType.EXPORT)
    @FileExport(fileName = "优化动作管理.xlsx")
    @PostMapping("/export")
    public String export(TOptimizeActions tOptimizeActions) throws IOException
    {
        List<TOptimizeActions> list = tOptimizeActionsService.getList(tOptimizeActions);
        return EasyExcelUtils.excelExport(TOptimizeActions.class,"优化动作管理数据", list);
    }

    /**
     * 获取优化动作管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('business:optimizeActions:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(tOptimizeActionsService.get(id));
    }

    /**
     * 新增优化动作管理
     */
    @PreAuthorize("@ss.hasPermi('business:optimizeActions:add')")
    @Log(title = "优化动作管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TOptimizeActions tOptimizeActions)
    {
        return toAjax(tOptimizeActionsService.insert(tOptimizeActions));
    }

    /**
     * 修改优化动作管理
     */
    @PreAuthorize("@ss.hasPermi('business:optimizeActions:edit')")
    @Log(title = "优化动作管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TOptimizeActions tOptimizeActions)
    {
        return toAjax(tOptimizeActionsService.update(tOptimizeActions));
    }

    /**
     * 删除优化动作管理
     */
    @PreAuthorize("@ss.hasPermi('business:optimizeActions:remove')")
    @Log(title = "优化动作管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tOptimizeActionsService.deleteByIds(ids));
    }

    /**
     * 获取所有优化动作管理列表
     * @return
     */
    @GetMapping("/getAllList")
    public AjaxResult getAllList()
    {
        List<TOptimizeActions> list = tOptimizeActionsService.getAllList();
        return success(list);
    }
}
